/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.pacis.shca.domain.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author solriver
 */
@Entity
@Table(name = "historial_domicilio", catalog = "bdshca")
@NamedQueries({
    @NamedQuery(name = "HistorialDomicilio.findAll", query = "SELECT h FROM HistorialDomicilio h"),
    @NamedQuery(name = "HistorialDomicilio.findByGruIdGrupoFamiliar", query = "SELECT h FROM HistorialDomicilio h WHERE h.historialDomicilioPK.gruIdGrupoFamiliar = :gruIdGrupoFamiliar"),
    @NamedQuery(name = "HistorialDomicilio.findByDomIdDomicilio", query = "SELECT h FROM HistorialDomicilio h WHERE h.historialDomicilioPK.domIdDomicilio = :domIdDomicilio"),
    @NamedQuery(name = "HistorialDomicilio.findByHisFechaEntrada", query = "SELECT h FROM HistorialDomicilio h WHERE h.hisFechaEntrada = :hisFechaEntrada"),
    @NamedQuery(name = "HistorialDomicilio.findByHisTiempoLlegada", query = "SELECT h FROM HistorialDomicilio h WHERE h.hisTiempoLlegada = :hisTiempoLlegada")})
public class ResidenceRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ResidenceRecordPK residenceRecordPK;
    @Column(name = "his_fecha_entrada")
    @Temporal(TemporalType.DATE)
    private Date hisFechaEntrada;
    @Column(name = "his_tiempo_llegada")
    @Temporal(TemporalType.TIME)
    private Date hisTiempoLlegada;
    @JoinColumn(name = "vis_id_visita_domiciliaria", referencedColumnName = "id_visita_domiciliaria")
    @ManyToOne(optional = false)
    private HomeVisit visIdVisitaDomiciliaria;
    @JoinColumn(name = "dom_id_domicilio", referencedColumnName = "id_domicilio", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Residence residence;
    @JoinColumn(name = "gru_id_grupo_familiar", referencedColumnName = "id_grupo_familiar", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private FamilyGroup familyGroup;

    public ResidenceRecord() {
    }

    public ResidenceRecord(ResidenceRecordPK residenceRecordPK) {
        this.residenceRecordPK = residenceRecordPK;
    }

    public ResidenceRecord(int gruIdGrupoFamiliar, int domIdDomicilio) {
        this.residenceRecordPK = new ResidenceRecordPK(gruIdGrupoFamiliar, domIdDomicilio);
    }

    public ResidenceRecordPK getResidenceRecordPK() {
        return residenceRecordPK;
    }

    public void setResidenceRecordPK(ResidenceRecordPK residenceRecordPK) {
        this.residenceRecordPK = residenceRecordPK;
    }

    public Date getHisFechaEntrada() {
        return hisFechaEntrada;
    }

    public void setHisFechaEntrada(Date hisFechaEntrada) {
        this.hisFechaEntrada = hisFechaEntrada;
    }

    public Date getHisTiempoLlegada() {
        return hisTiempoLlegada;
    }

    public void setHisTiempoLlegada(Date hisTiempoLlegada) {
        this.hisTiempoLlegada = hisTiempoLlegada;
    }

    public HomeVisit getVisIdVisitaDomiciliaria() {
        return visIdVisitaDomiciliaria;
    }

    public void setVisIdVisitaDomiciliaria(HomeVisit visIdVisitaDomiciliaria) {
        this.visIdVisitaDomiciliaria = visIdVisitaDomiciliaria;
    }

    public Residence getResidence() {
        return residence;
    }

    public void setResidence(Residence residence) {
        this.residence = residence;
    }

    public FamilyGroup getFamilyGroup() {
        return familyGroup;
    }

    public void setFamilyGroup(FamilyGroup familyGroup) {
        this.familyGroup = familyGroup;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (residenceRecordPK != null ? residenceRecordPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ResidenceRecord)) {
            return false;
        }
        ResidenceRecord other = (ResidenceRecord) object;
        if ((this.residenceRecordPK == null && other.residenceRecordPK != null) || (this.residenceRecordPK != null && !this.residenceRecordPK.equals(other.residenceRecordPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.pacis.shca.domain.entity.HistorialDomicilio[ historialDomicilioPK=" + residenceRecordPK + " ]";
    }
    
}
